//
//  UICollectionView+YSExtension.m
//  YSWeChat
//
//  Created by MOLBASE on 2018/4/15.
//  Copyright © 2018年 YangShen. All rights reserved.
//

#import "UICollectionView+YSExtension.h"

@implementation UICollectionView (YSExtension)

- (void)ys_registerCell:(Class)cls {
    [self registerClass:cls forCellWithReuseIdentifier:NSStringFromClass(cls)];
}

- (void)ys_registerNibCell:(Class)cls {
    [self ys_registerNibCell:cls forCellReuseIdentifier:NSStringFromClass(cls)];
}

- (void)ys_registerNibCell:(Class)cls forCellReuseIdentifier:(NSString *)reuseIdentifier {
    [self registerNib:[UINib nibWithNibName:NSStringFromClass(cls) bundle:nil] forCellWithReuseIdentifier:reuseIdentifier];
}

- (__kindof UICollectionViewCell *)ys_dequeueReusableCell:(Class)cls forIndexPath:(NSIndexPath *)indexPath {
    return [self dequeueReusableCellWithReuseIdentifier:NSStringFromClass(cls) forIndexPath:indexPath];
}

- (void)ys_registerFooterView:(Class)cls {
    [self registerClass:cls forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:NSStringFromClass(cls)];
}

- (void)ys_registerFooterView:(Class)cls withReuseIdentifier:(NSString *)reuseIdentifier {
    [self registerClass:cls forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:NSStringFromClass(cls)];
}

- (void)ys_registerNibFooterView:(Class)cls {
    [self ys_registerNibFooterView:cls withReuseIdentifier:NSStringFromClass(cls)];
}

- (void)ys_registerNibFooterView:(Class)cls withReuseIdentifier:(NSString *)reuseIdentifier {
    [self registerNib:[UINib nibWithNibName:NSStringFromClass(cls) bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:NSStringFromClass(cls)];
}

- (void)ys_registerHeaderView:(Class)cls {
    [self registerClass:cls forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:NSStringFromClass(cls)];
}

- (void)ys_registerHeaderView:(Class)cls withReuseIdentifier:(NSString *)reuseIdentifier {
    [self registerClass:cls forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:NSStringFromClass(cls)];
}

- (void)ys_registerNibHeaderView:(Class)cls {
    [self ys_registerNibHeaderView:cls withReuseIdentifier:NSStringFromClass(cls)];
}

- (void)ys_registerNibHeaderView:(Class)cls withReuseIdentifier:(NSString *)reuseIdentifier {
    [self registerNib:[UINib nibWithNibName:NSStringFromClass(cls) bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:NSStringFromClass(cls)];
}

- (__kindof UICollectionReusableView *)ys_dequeueReusableHeaderView:(Class)cls forIndexPath:(NSIndexPath *)indexPath {
    return [self dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:NSStringFromClass(cls) forIndexPath:indexPath];
}

- (__kindof UICollectionReusableView *)ys_dequeueReusableFooterView:(Class)cls forIndexPath:(NSIndexPath *)indexPath {
    return [self dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:NSStringFromClass(cls) forIndexPath:indexPath];
}

@end
